package command;


import java.io.IOException;

import javax.swing.JButton;

import xml.LoadXML;
import xml.SaveXML;
import arbori.ArboreFunctional;
import arbori.Nod;

public class IncarcareXML extends JButton implements Command {
	
	protected ArboreFunctional a;
	protected String fisier;

	public IncarcareXML(String nume)
	{
		super(nume);
	}
	public Nod getArbore()
	{
		return a.getRadacina();
	}
	public void setFisier(String n)
	{
		this.fisier=n;
	}
	
	/**
	 * apeleaza functia care incarca si parseaza un fisier XML
	 */
	public void execute()
	{
		try{
		LoadXML lxml=new LoadXML(fisier);
		a=new ArboreFunctional(lxml.getArbore().getRadacina());
		ArgDependentCommand.setFunctie(a);
		}catch(IOException e){System.out.println("Eroare incarcare XML!!!");}

	}
   
}

